<style media="print">
    @page {
        size: auto;  /* auto is the initial value */
        margin: 0mm; /* this affects the margin in the printer settings */
    }
</style>
    <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="" style="font-size: 15px">
    <div style="text-align: center;font-size: 30px">
        <span >厂家直发单</span>
    </div>
    <div class="content">
        <div class="panel panel-default panel-intro">

            <div class="panel-body">
                <div id="myTabContent" class="tab-content">
                    <div class="tab-pane fade active in" id="one">
                        <div class="widget-body no-padding">

                            <div class="bootstrap-table">
                                <div class="commonsearch-table ">
                                    <fieldset>
                                        <div class="row">

                                            <div class="" style="float: left;width:25%">
                                                <label  style="float: left" for="operator" >&nbsp;&nbsp;&nbsp;&nbsp;订单编号 : </label>
                                                <div class="" style="float: left">
                                                    <span class="">{$row.number}</span>
                                                </div>
                                            </div>

                                            <div class="" style="float: left;width:25%">
                                                <label  style="float: left" for="operator" >&nbsp;&nbsp;&nbsp;&nbsp;供应商 : </label>
                                                <div class="" style="float: left">
                                                    <span class="">{$row.supplier_name}</span>
                                                </div>
                                            </div>
                                            <div class="" style="float: left;width:25%">
                                                <label  style="float: left" for="operator" >&nbsp;&nbsp;&nbsp;&nbsp;订单日期 : </label>
                                                <div class="" style="float: left">
                                                    <span class="">{$row.createtime|date='Y-m-d',###}</span>
                                                </div>
                                            </div>
                                            <div class="" style="float: left;width:25%">
                                                <label  style="float: left" for="operator" >&nbsp;&nbsp;&nbsp;&nbsp;部门单位 : </label>
                                                <div class="" style="float: left">
                                                    <span class="">{$row.company}</span>
                                                </div>
                                            </div>
                                            <div class="" style="float: left;width:25%">
                                                <label  style="float: left" for="operator" >&nbsp;&nbsp;&nbsp;&nbsp;业务员 : </label>
                                                <div class="" style="float: left">
                                                    <span class="">{$row.operator}</span>
                                                </div>
                                            </div>

                                            <div class="" style="float: left;width:25%">
                                                <label  style="float: left" for="operator" >&nbsp;&nbsp;&nbsp;&nbsp;客户 : </label>
                                                <div class="" style="float: left">
                                                    <span class="">{$row.customer_name}</span>
                                                </div>
                                            </div>
                                            <div class="" style="float: left;width:25%">
                                                <label  style="float: left" for="operator" >&nbsp;&nbsp;&nbsp;&nbsp;联系人 : </label>
                                                <div class="" style="float: left">
                                                    <span class="">{$row.contacts}</span>
                                                </div>
                                            </div>
                                            <div class="" style="float: left;width:25%">
                                                <label  style="float: left" for="operator" >&nbsp;&nbsp;&nbsp;&nbsp;收货地址 : </label>
                                                <div class="" style="float: left">
                                                    <span class="">{$row.address}</span>
                                                </div>
                                            </div>
                                            <div class="" style="float: left;width:25%">
                                                <label  style="float: left" for="operator" >&nbsp;&nbsp;&nbsp;&nbsp;手机 : </label>
                                                <div class="" style="float: left">
                                                    <span class="">{$row.mobile}</span>
                                                </div>
                                            </div>
                                            <div class="" style="float: left;width:25%">
                                                <label  style="float: left" for="operator" >&nbsp;&nbsp;&nbsp;&nbsp;说明 : </label>
                                                <div class="" style="float: left">
                                                    <span class="">{$row.explain}</span>
                                                </div>
                                            </div>
                                            <div class="" style="float: left;width:25%">
                                                <label  style="float: left" for="operator" >&nbsp;&nbsp;&nbsp;&nbsp;运费 : </label>
                                                <div class="" style="float: left">
                                                    <span class="">{$row.unit_allfare}</span>
                                                </div>
                                            </div>
                                        </div>
                                </div>
                                </fieldset>
                            </div>
                        </div>


<!--                        <div class="fixed-table-toolbar"><div class="bs-bars pull-left"><div id="toolbar" class="toolbar" style="position: relative;">-->
<!--                            <a href="javascript:;" class="btn btn-success btn-add " title="添加"><i class="fa fa-plus"></i> 添加</a>-->
<!--                        </div>-->
                        </div><div class="columns-right pull-right" style="margin-top:10px;margin-bottom:10px;">
                        </div>
                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"  data-operate-edit="1" data-operate-del="1" width="100%" >
                                <thead>
                                <tr>
                                    <th style="text-align: center; vertical-align: middle; " data-field="id"><div class="th-inner ">Id</div></th>
                                    <!--                                <th style="text-align: center; vertical-align: middle; " data-field="createtime"><div class="th-inner ">出库仓库</div></th>-->
                                    <th style="text-align: center; vertical-align: middle; " ><div class="th-inner ">商品编号</div></th>
                                    <th style="text-align: center; vertical-align: middle; " data-field="number"><div class="th-inner ">商品名称</div></th>
<!--                                    <th style="text-align: center; vertical-align: middle; " data-field="status"><div class="th-inner ">产地</div></th>-->
                                    <th style="text-align: center; vertical-align: middle; " data-field="supplier_id"><div class="th-inner ">规格</div></th>
                                    <th style="text-align: center; vertical-align: middle; " data-field="order_goods_total"><div class="th-inner ">销售数量</div><div class="fht-cell"></div></th>
<!--                                    <th style="text-align: center; vertical-align: middle; " data-field="order_goods_total"><div class="th-inner ">出库数量</div><div class="fht-cell"></div></th>-->
<!--                                    <th style="text-align: center; vertical-align: middle; " data-field="arrival_total"><div class="th-inner ">销售单位</div><div class="fht-cell"></div></th>-->
                                    <th style="text-align: center; vertical-align: middle; " data-field="order_price"><div class="th-inner ">单价</div><div class="fht-cell"></div></th>
                                    <th style="text-align: center; vertical-align: middle; " data-field="order_price"><div class="th-inner ">采购额</div><div class="fht-cell"></div></th>
                                    <th style="text-align: center; vertical-align: middle; " data-field="arrival_price"><div class="th-inner ">采购税点</div><div class="fht-cell"></div></th>
                                    <th style="text-align: center; vertical-align: middle; " data-field="paid_in_price"><div class="th-inner ">采购价</div><div class="fht-cell"></div></th>
                                    <th style="text-align: center; vertical-align: middle; " data-field="paid_in_price"><div class="th-inner ">采购税额</div><div class="fht-cell"></div></th>
                                    <!--                                <th style="text-align: center; vertical-align: middle; " data-field="explain"><div class="th-inner ">所有运费</div><div class="fht-cell"></div></th>-->
                                    <!--                                <th style="text-align: center; vertical-align: middle; " data-field="explain"><div class="th-inner ">单件运费</div><div class="fht-cell"></div></th>-->
                                    <th style="text-align: center; vertical-align: middle; " data-field="explain"><div class="th-inner ">采购合计</div><div class="fht-cell"></div></th>
                                    <th style="text-align: center; vertical-align: middle; " data-field="operate"><div class="th-inner ">备注</div><div class="fht-cell"></div></th>
                                </tr>
                                </thead>
                                <tbody data-listidx="0" class="connnn" >
                                {volist name="rows" id="vo"}
                                        <tr data-index="0"  >
                                            <td style="text-align: center; vertical-align: middle; ">{$key+1}</td>
                                            <td style="text-align: center; vertical-align: middle; ">{$vo.number}</td>
                                            <td style="text-align: center; vertical-align: middle;white-space: nowrap;weight:100%; ">{$vo.title}</td>
<!--                                            <td style="text-align: center; vertical-align: middle; ">{$vo.place_origin}</td>-->
                                            <td style="text-align: center; vertical-align: middle; " >{$vo.specs}</td>
                                            <td style="text-align: center; vertical-align: middle; " class="goods_num">{$vo.goods_num}</td>
<!--                                            <td style="text-align: center; vertical-align: middle; ">{$vo.unit}</td>-->
                                            <td style="text-align: center; vertical-align: middle; " >{$vo.unit_price}</span></td>
                                            <td style="text-align: center; vertical-align: middle; " class="buy_price">{$vo.unit_price*$vo.goods_num}</td>
                                            <td style="text-align: center; vertical-align: middle; " >{$vo.unit_tax}</td>
                                            <td style="text-align: center; vertical-align: middle; " >{$vo.unit_ht_price} </td>
                                            <td style="text-align: center; vertical-align: middle; " class="tax_all">{$vo.tax_all}</td>
                                            <td style="text-align: center; vertical-align: middle; " class="ht_price">{$vo.unit_ht_price*$vo.goods_num}</span> </td>
                                            <td style="text-align: center; vertical-align: middle; min-width: 100px;
                                                        white-space: nowrap;
                                                        text-overflow:ellipsis;
                                                        overflow:hidden;
                                                        max-width: 120px" class="remark">{$vo.remark}</td>
                                        </tr>
                                {/volist}
                                </tbody>

                                <tbody class="tbfoot" data-listidx="0" style="display: ">
                                    <td style="text-align: center; vertical-align: middle; ">合计</td>
                                    <td style="text-align: center; vertical-align: middle; "></td>
<!--                                    <td style="text-align: center; vertical-align: middle; "></td>-->
<!--                                    <td style="text-align: center; vertical-align: middle; "></td>-->
                                    <td style="text-align: center; vertical-align: middle; "></td>
                                    <td style="text-align: center; vertical-align: middle; " class="allnum"></td>
<!--                                    <td style="text-align: center; vertical-align: middle; "></td>-->
                                    <td style="text-align: center; vertical-align: middle; "></td>
                                    <td style="text-align: center; vertical-align: middle; " ></td>
                                    <td style="text-align: center; vertical-align: middle; "class="alprice">{$money.purche}</td>
                                    <td style="text-align: center; vertical-align: middle; "></td>
                                    <td style="text-align: center; vertical-align: middle; "></td>
                                    <td style="text-align: center; vertical-align: middle; "class="alltax">{$taxmoney.purche}</td>
                                    <td style="text-align: center; vertical-align: middle; "class="all_cost">{$allmoney.purche}</td>
                                    <td style="text-align: center; vertical-align: middle; "></td>
                                </tbody>
                            </table>
                        </div>
                <br>
                <div class="widget-body no-padding">
                    <div class="bootstrap-table">
                        <div class="commonsearch-table ">
                            <fieldset>
                                <div class="row">
                                    <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3" style="display: none">
                                        <label for="discount" class="control-label col-xs-4">优惠</label>
                                        <div class="col-xs-8">
                                            <input type="text" class="form-control " name="discount" value="0" placeholder="优惠" id="discount" data-index="7" onkeyup="checkInputIntFloat(this);">
                                        </div>
                                    </div>
                                    <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3" style="display: none">
                                        <label for="c-discount_explain" class="control-label col-xs-4">优惠说明</label>
                                        <div class="col-xs-8">
                                            <input id="c-discount-explain"   class="form-control " name="discount_explain" type="text" value="" >
                                        </div>
                                    </div>
                                    <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">
                                        <label for="c-actual_cost" class="control-label col-xs-4">总费用</label>
                                        <div class="col-xs-8">
                                            <input id="c-actual-cost" data-rule="required"  class="form-control actual_cost" name="actual-cost" type="text" value="{$allmoney.purche+$row.unit_allfare}" disabled>
                                            <input  data-rule="required"  class="form-control actual_cost" name="actual_cost" type="text" value="0" style="display: none">
                                        </div>
                                    </div>
                                </div>
                            </fieldset>
                        </div>
                    </div>
                </div>

            </div>





                    </div>
                </div>

            </div>
        </form>
    </div>
</div>


<div class="form-group layer-footer">
    <a class="btn btn-outline-success" href="javascript:printHTML('#add-form')" target="_self" style="margin-left: 20px">打印</a>
    <!--    <a class="btn btn-outline-success  printing" href="###" target="_self" style="margin-left: 20px" >打印</a>-->
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
<script>
    function printHTML(page)
    {
        var bodyHTML=window.document.body.innerHTML;
        window.document.body.innerHTML=$(page).html();
        window.print();
        setTimeout(function () {
            window.document.body.innerHTML=bodyHTML;
        },1800)
        return false
    }

    $('body').on('mouseenter','.remark',function () {
        if (this.offsetWidth < this.scrollWidth) {
            var that = this;
            var text = $(this).text();
            layer.tips(text, that,{
                tips: 1,
                time: 2000         //设置显示时间
            });
        }
    })


    // getcustomer()
    function getcustomer() {
        var cid = "{$row.customer_id}"
        if(cid == ''){
            return  false;
        }
        customer_id = cid;
        var url = "{$turl}"+'/customer/customer/detail?ids='+cid
        $.post(url,{},function (res) {
            $('#default_mobile').val(res.mobile)
            $('#default_address').val(res.address)
            $('#default_contacts').val(res.nickname)
        })
    }

    // count()
    function count() {
        if($(".connnn > tr").length == 0){
            $('.tbfoot').attr('style','display:none')
            return false;
        }

        var alprice = 0;//销售金额
        var allnum = 0;//销售数量
        var alltax = 0;//税额
        var fare = 0;//税费合计
        var all_cost = 0;//运运费合计


        $('.connnn').find("tr").each(function(){
            var goods_num = $(this).find('.goods_num').html()*1;
            var buy_price = $(this).find('.buy_price').html()*1;
            var tax_all = $(this).find('.tax_all').html()*1;
            // var all_fare = $(this).find('.all_fare').html()*1;
            var ht_price = $(this).find('.ht_price').html()*1;
            allnum= allnum+goods_num
            alprice= buy_price+alprice
            alltax= alltax+tax_all
            // fare= fare+all_fare
            all_cost= all_cost+ht_price
        });
        $('.alprice').html(alprice.toFixed(2))
        $('.allnum').html(allnum)
        $('.alltax').html(alltax.toFixed(2))
        // $('.fare').html(fare)
        $('.all_cost').html(all_cost.toFixed(2))
    }



</script>
